<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="90px">
      <el-form-item label="工厂名称" prop="factoryName">
        <el-input
          v-model="queryParams.factoryName"
          placeholder="请输入工厂名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="采购单号" prop="danhao">
        <el-input
          v-model="queryParams.danhao"
          placeholder="请输入采购单号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="要货单号" prop="yhDanhao">
        <el-input
          v-model="queryParams.yhDanhao"
          placeholder="请输入要货单号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="ASN编号-订单号" prop="asnDanhao">
        <el-input
          v-model="queryParams.asnDanhao"
          placeholder="请输入ASN编号-订单号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="物料类型id" prop="classId">
        <el-input
          v-model="queryParams.classId"
          placeholder="请输入物料类型id"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="物料类型" prop="className">
        <el-input
          v-model="queryParams.className"
          placeholder="请输入物料类型"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="物料名称" prop="itemName">
        <el-input
          v-model="queryParams.itemName"
          placeholder="请输入物料名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="物料子编号" prop="itemId">
        <el-input
          v-model="queryParams.itemId"
          placeholder="请输入物料子编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="物料编号" prop="itemCode">
        <el-input
          v-model="queryParams.itemCode"
          placeholder="请输入物料编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="供应商名称" prop="supplyName">
        <el-input
          v-model="queryParams.supplyName"
          placeholder="请输入供应商名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="制造商名称" prop="makerName">
        <el-input
          v-model="queryParams.makerName"
          placeholder="请输入制造商名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="合同编号" prop="contractCode">
        <el-input
          v-model="queryParams.contractCode"
          placeholder="请输入合同编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="年度采购计划号" prop="ncgPlanId">
        <el-input
          v-model="queryParams.ncgPlanId"
          placeholder="请输入年度采购计划号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="季度采购计划号" prop="jcgPlanId">
        <el-input
          v-model="queryParams.jcgPlanId"
          placeholder="请输入季度采购计划号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="月度采购计划号" prop="ycgPlanId">
        <el-input
          v-model="queryParams.ycgPlanId"
          placeholder="请输入月度采购计划号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="临时采购计划号" prop="lscgPlanId">
        <el-input
          v-model="queryParams.lscgPlanId"
          placeholder="请输入临时采购计划号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['business:purchaseInfoSp:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['business:purchaseInfoSp:edit']"
        >修改</el-button>
      </el-col>
      purchaseInfo
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['business:purchaseInfoSp:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['business:purchaseInfoSp:export']"
        >导出</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
            type="info"
            plain
            icon="el-icon-upload2"
            size="mini"
            @click="handleImport"
        >导入</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="purchaseInfoSpList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="主键" align="center" prop="id" />
      <el-table-column label="工厂名称" align="center" prop="factoryName" />
      <el-table-column label="工厂代码" align="center" prop="factoryCode" />
      <el-table-column label="采购单号" align="center" prop="danhao" />
      <el-table-column label="要货单号" align="center" prop="yhDanhao" />
      <el-table-column label="ASN编号-订单号" align="center" prop="asnDanhao" />
      <el-table-column label="物料类型id" align="center" prop="classId" />
      <el-table-column label="物料类型" align="center" prop="className" />
      <el-table-column label="物料名称" align="center" prop="itemName" />
      <el-table-column label="物料子编号" align="center" prop="itemId" />
      <el-table-column label="物料编号" align="center" prop="itemCode" />
      <el-table-column label="规格型号" align="center" prop="spec" />
      <el-table-column label="物料单位" align="center" prop="unit" />
      <el-table-column label="条形码" align="center" prop="txm" />
      <el-table-column label="供应商编码" align="center" prop="supplyId" />
      <el-table-column label="供应商名称" align="center" prop="supplyName" />
      <el-table-column label="制造商编码" align="center" prop="makerCode" />
      <el-table-column label="制造商名称" align="center" prop="makerName" />
      <el-table-column label="合同编号" align="center" prop="contractCode" />
      <el-table-column label="合同数量" align="center" prop="contractNum" />
      <el-table-column label="合同份额" align="center" prop="contractShare" />
      <el-table-column label="计划单价" align="center" prop="jhUnitPrice" />
      <el-table-column label="计划总价" align="center" prop="jhTotalPrice" />
      <el-table-column label="总价" align="center" prop="totalPrice" />
      <el-table-column label="单价" align="center" prop="unitPrice" />
      <el-table-column label="托管属性" align="center" prop="isTuoguan" />
      <el-table-column label="要货数量" align="center" prop="yhNum" />
      <el-table-column label="送货数量" align="center" prop="shNum" />
      <el-table-column label="入库数量" align="center" prop="rkNum" />
      <el-table-column label="合格数量" align="center" prop="hgNum" />
      <el-table-column label="退货数量" align="center" prop="thNum" />
      <el-table-column label="要货类型" align="center" prop="yhType" />
      <el-table-column label="要货单位" align="center" prop="yhCompany" />
      <el-table-column label="物流单位" align="center" prop="wlCompany" />
      <el-table-column label="订货单位" align="center" prop="dhCompany" />
      <el-table-column label="要货时间" align="center" prop="yhTime" width="180"/>
      <el-table-column label="订货仓库" align="center" prop="dhStock" />
      <el-table-column label="收货人" align="center" prop="shName" />
      <el-table-column label="收货位" align="center" prop="shKuwei" />
      <el-table-column label="收货地址" align="center" prop="shAddress" />
      <el-table-column label="供货单位" align="center" prop="ghCompany" />
      <el-table-column label="供货周期" align="center" prop="ghDate" />
      <el-table-column label="供货地址" align="center" prop="ghAddress" />
      <el-table-column label="生产周期" align="center" prop="scDate" />
      <el-table-column label="供应商运输距离" align="center" prop="gysYsjl" />
      <el-table-column label="供应商运输时间" align="center" prop="gysYssj" />
      <el-table-column label="月订单数量" align="center" prop="yddNum" />
      <el-table-column label="月完成数量" align="center" prop="ywcNum" />
      <el-table-column label="月度供货未完成比率" align="center" prop="yghwcbl" />
      <el-table-column label="单箱容量" align="center" prop="dxrl" />
      <el-table-column label="年度采购计划号" align="center" prop="ncgPlanId" />
      <el-table-column label="年度采购计划数量" align="center" prop="ncgPlanNum" />
      <el-table-column label="季度采购计划号" align="center" prop="jcgPlanId" />
      <el-table-column label="季度采购计划数量" align="center" prop="jcgPlanNum" />
      <el-table-column label="月度采购计划号" align="center" prop="ycgPlanId" />
      <el-table-column label="月度采购计划数量" align="center" prop="ycgPlanNum" />
      <el-table-column label="临时采购计划号" align="center" prop="lscgPlanId" />
      <el-table-column label="临时采购计划数量" align="center" prop="lscgPlanNum" />
      <el-table-column label="尺寸" align="center" prop="size" />
      <el-table-column label="单重" align="center" prop="singleWeight" />
      <el-table-column label="总重" align="center" prop="totalWeight" />
      <el-table-column label="入库时间" align="center" prop="rukuDate" width="180"/>
      <el-table-column label="库存上限" align="center" prop="upLine" />
      <el-table-column label="库存下限" align="center" prop="downLine" />
      <el-table-column label="安全库存" align="center" prop="stockSafe" />
      <el-table-column label="使用状态" align="center" prop="useState" />
      <el-table-column label="颜色" align="center" prop="color" />
      <el-table-column label="花纹" align="center" prop="figure" />
      <el-table-column label="材质" align="center" prop="caizhi" />
      <el-table-column label="是否呆滞" align="center" prop="isDaizhi" />
      <el-table-column label="包装数量" align="center" prop="packingNum" />
      <el-table-column label="包装尺寸" align="center" prop="packingSize" />
      <el-table-column label="包装材质" align="center" prop="packingCaizhi" />
      <el-table-column label="采购人" align="center" prop="cgName" />
      <el-table-column label="审批状态" align="center" prop="shenhFlag" />
      <el-table-column label="审核时间" align="center" prop="shenhTime" width="180"/>
      <el-table-column label="审批意见" align="center" prop="shenhRemark" />
      <el-table-column label="审核人" align="center" prop="shenhName" />
      <el-table-column label="审批状态0-不同意" align="center" prop="shenhState" />
      <el-table-column label="备注" align="center" prop="remark" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['business:purchaseInfoSp:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['business:purchaseInfoSp:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改采购审批单对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="90px">
        <el-row :gutter="24">
          <el-col :span="12">
            <el-form-item label="工厂名称" prop="factoryName">
              <el-input v-model="form.factoryName" placeholder="请输入工厂名称" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="工厂代码" prop="factoryCode">
              <el-input v-model="form.factoryCode" placeholder="请输入工厂代码" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="采购单号" prop="danhao">
              <el-input v-model="form.danhao" placeholder="请输入采购单号" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="要货单号" prop="yhDanhao">
              <el-input v-model="form.yhDanhao" placeholder="请输入要货单号" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="ASN编号-订单号" prop="asnDanhao">
              <el-input v-model="form.asnDanhao" placeholder="请输入ASN编号-订单号" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="物料类型id" prop="classId">
              <el-input v-model="form.classId" placeholder="请输入物料类型id" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="物料类型" prop="className">
              <el-input v-model="form.className" placeholder="请输入物料类型" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="物料名称" prop="itemName">
              <el-input v-model="form.itemName" placeholder="请输入物料名称" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="物料子编号" prop="itemId">
              <el-input v-model="form.itemId" placeholder="请输入物料子编号" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="物料编号" prop="itemCode">
              <el-input v-model="form.itemCode" placeholder="请输入物料编号" />
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="规格型号" prop="spec">
              <el-input v-model="form.spec" type="textarea" placeholder="请输入内容" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="物料单位" prop="unit">
              <el-input v-model="form.unit" placeholder="请输入物料单位" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="条形码" prop="txm">
              <el-input v-model="form.txm" placeholder="请输入条形码" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="供应商编码" prop="supplyId">
              <el-input v-model="form.supplyId" placeholder="请输入供应商编码" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="供应商名称" prop="supplyName">
              <el-input v-model="form.supplyName" placeholder="请输入供应商名称" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="制造商编码" prop="makerCode">
              <el-input v-model="form.makerCode" placeholder="请输入制造商编码" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="制造商名称" prop="makerName">
              <el-input v-model="form.makerName" placeholder="请输入制造商名称" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="合同编号" prop="contractCode">
              <el-input v-model="form.contractCode" placeholder="请输入合同编号" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="合同数量" prop="contractNum">
              <el-input v-model="form.contractNum" placeholder="请输入合同数量" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="合同份额" prop="contractShare">
              <el-input v-model="form.contractShare" placeholder="请输入合同份额" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="计划单价" prop="jhUnitPrice">
              <el-input v-model="form.jhUnitPrice" placeholder="请输入计划单价" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="计划总价" prop="jhTotalPrice">
              <el-input v-model="form.jhTotalPrice" placeholder="请输入计划总价" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="总价" prop="totalPrice">
              <el-input v-model="form.totalPrice" placeholder="请输入总价" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="单价" prop="unitPrice">
              <el-input v-model="form.unitPrice" placeholder="请输入单价" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="托管属性" prop="isTuoguan">
              <el-input v-model="form.isTuoguan" placeholder="请输入托管属性" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="要货数量" prop="yhNum">
              <el-input v-model="form.yhNum" placeholder="请输入要货数量" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="送货数量" prop="shNum">
              <el-input v-model="form.shNum" placeholder="请输入送货数量" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="入库数量" prop="rkNum">
              <el-input v-model="form.rkNum" placeholder="请输入入库数量" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="合格数量" prop="hgNum">
              <el-input v-model="form.hgNum" placeholder="请输入合格数量" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="退货数量" prop="thNum">
              <el-input v-model="form.thNum" placeholder="请输入退货数量" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="要货单位" prop="yhCompany">
              <el-input v-model="form.yhCompany" placeholder="请输入要货单位" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="物流单位" prop="wlCompany">
              <el-input v-model="form.wlCompany" placeholder="请输入物流单位" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="订货单位" prop="dhCompany">
              <el-input v-model="form.dhCompany" placeholder="请输入订货单位" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="要货时间" prop="yhTime">
              <el-date-picker clearable
                v-model="form.yhTime"
                type="date"
                value-format="yyyy-MM-dd HH:mm:ss"
                placeholder="请选择要货时间">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="订货仓库" prop="dhStock">
              <el-input v-model="form.dhStock" placeholder="请输入订货仓库" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="收货人" prop="shName">
              <el-input v-model="form.shName" placeholder="请输入收货人" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="收货位" prop="shKuwei">
              <el-input v-model="form.shKuwei" placeholder="请输入收货位" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="收货地址" prop="shAddress">
              <el-input v-model="form.shAddress" placeholder="请输入收货地址" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="供货单位" prop="ghCompany">
              <el-input v-model="form.ghCompany" placeholder="请输入供货单位" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="供货周期" prop="ghDate">
              <el-input v-model="form.ghDate" placeholder="请输入供货周期" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="供货地址" prop="ghAddress">
              <el-input v-model="form.ghAddress" placeholder="请输入供货地址" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="生产周期" prop="scDate">
              <el-input v-model="form.scDate" placeholder="请输入生产周期" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="供应商运输距离" prop="gysYsjl">
              <el-input v-model="form.gysYsjl" placeholder="请输入供应商运输距离" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="供应商运输时间" prop="gysYssj">
              <el-input v-model="form.gysYssj" placeholder="请输入供应商运输时间" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="月订单数量" prop="yddNum">
              <el-input v-model="form.yddNum" placeholder="请输入月订单数量" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="月完成数量" prop="ywcNum">
              <el-input v-model="form.ywcNum" placeholder="请输入月完成数量" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="月度供货未完成比率" prop="yghwcbl">
              <el-input v-model="form.yghwcbl" placeholder="请输入月度供货未完成比率" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="单箱容量" prop="dxrl">
              <el-input v-model="form.dxrl" placeholder="请输入单箱容量" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="年度采购计划号" prop="ncgPlanId">
              <el-input v-model="form.ncgPlanId" placeholder="请输入年度采购计划号" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="年度采购计划数量" prop="ncgPlanNum">
              <el-input v-model="form.ncgPlanNum" placeholder="请输入年度采购计划数量" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="季度采购计划号" prop="jcgPlanId">
              <el-input v-model="form.jcgPlanId" placeholder="请输入季度采购计划号" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="季度采购计划数量" prop="jcgPlanNum">
              <el-input v-model="form.jcgPlanNum" placeholder="请输入季度采购计划数量" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="月度采购计划号" prop="ycgPlanId">
              <el-input v-model="form.ycgPlanId" placeholder="请输入月度采购计划号" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="月度采购计划数量" prop="ycgPlanNum">
              <el-input v-model="form.ycgPlanNum" placeholder="请输入月度采购计划数量" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="临时采购计划号" prop="lscgPlanId">
              <el-input v-model="form.lscgPlanId" placeholder="请输入临时采购计划号" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="临时采购计划数量" prop="lscgPlanNum">
              <el-input v-model="form.lscgPlanNum" placeholder="请输入临时采购计划数量" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="尺寸" prop="size">
              <el-input v-model="form.size" placeholder="请输入尺寸" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="单重" prop="singleWeight">
              <el-input v-model="form.singleWeight" placeholder="请输入单重" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="总重" prop="totalWeight">
              <el-input v-model="form.totalWeight" placeholder="请输入总重" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="入库时间" prop="rukuDate">
              <el-date-picker clearable
                v-model="form.rukuDate"
                type="date"
                value-format="yyyy-MM-dd HH:mm:ss"
                placeholder="请选择入库时间">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="库存上限" prop="upLine">
              <el-input v-model="form.upLine" placeholder="请输入库存上限" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="库存下限" prop="downLine">
              <el-input v-model="form.downLine" placeholder="请输入库存下限" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="安全库存" prop="stockSafe">
              <el-input v-model="form.stockSafe" placeholder="请输入安全库存" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="使用状态" prop="useState">
              <el-input v-model="form.useState" placeholder="请输入使用状态" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="颜色" prop="color">
              <el-input v-model="form.color" placeholder="请输入颜色" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="花纹" prop="figure">
              <el-input v-model="form.figure" placeholder="请输入花纹" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="材质" prop="caizhi">
              <el-input v-model="form.caizhi" placeholder="请输入材质" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="是否呆滞" prop="isDaizhi">
              <el-input v-model="form.isDaizhi" placeholder="请输入是否呆滞" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="包装数量" prop="packingNum">
              <el-input v-model="form.packingNum" placeholder="请输入包装数量" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="包装尺寸" prop="packingSize">
              <el-input v-model="form.packingSize" placeholder="请输入包装尺寸" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="包装材质" prop="packingCaizhi">
              <el-input v-model="form.packingCaizhi" placeholder="请输入包装材质" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="采购人" prop="cgName">
              <el-input v-model="form.cgName" placeholder="请输入采购人" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="审批状态" prop="shenhFlag">
              <el-input v-model="form.shenhFlag" placeholder="请输入审批状态" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="审核时间" prop="shenhTime">
              <el-date-picker clearable
                v-model="form.shenhTime"
                type="date"
                value-format="yyyy-MM-dd HH:mm:ss"
                placeholder="请选择审核时间">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="审批意见" prop="shenhRemark">
              <el-input v-model="form.shenhRemark" placeholder="请输入审批意见" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="审核人" prop="shenhName">
              <el-input v-model="form.shenhName" placeholder="请输入审核人" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="审批状态0-不同意" prop="shenhState">
              <el-input v-model="form.shenhState" placeholder="请输入审批状态0-不同意" />
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="备注" prop="remark">
              <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
      <el-upload
          ref="upload"
          :limit="1"
          accept=".xlsx, .xls"
          :headers="upload.headers"
          :action="upload.url + '?updateSupport=' + upload.updateSupport"
          :disabled="upload.isUploading"
          :on-progress="handleFileUploadProgress"
          :on-success="handleFileSuccess"
          :auto-upload="false"
          drag
      >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
        <div class="el-upload__tip text-center" slot="tip">
          <!--  <div class="el-upload__tip" slot="tip">
              <el-checkbox v-model="upload.updateSupport" /> 是否更新已经存在的用户数据
            </div>-->
          <span>仅允许导入xls、xlsx格式文件。</span>
          <el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;" @click="importTemplate">下载模板</el-link>
        </div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm">确 定</el-button>
        <el-button @click="upload.open = false">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listPurchaseInfoSp, getPurchaseInfoSp, delPurchaseInfoSp, addPurchaseInfoSp, updatePurchaseInfoSp } from "@/api/business/purchaseInfoSp";
import {getToken} from "@/utils/auth";
export default {
  name: "PurchaseInfoSp",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 采购审批单表格数据
      purchaseInfoSpList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        factoryName: null,
        danhao: null,
        yhDanhao: null,
        asnDanhao: null,
        classId: null,
        className: null,
        itemName: null,
        itemId: null,
        itemCode: null,
        spec: null,
        supplyName: null,
        makerName: null,
        contractCode: null,
        yhType: null,
        ncgPlanId: null,
        jcgPlanId: null,
        ycgPlanId: null,
        lscgPlanId: null,
      },
      upload: {
        // 是否显示弹出层
        open: false,
        // 弹出层标题
        title: "导入`purchaseInfoSp`信息",
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的用户数据
        updateSupport: 0,
        // 设置上传的请求头部
        headers: { Authorization: "Bearer " + getToken() },
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/business/purchaseInfoSp/importData"
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询采购审批单列表 */
    getList() {
      this.loading = true;
      listPurchaseInfoSp(this.queryParams).then(response => {
        this.purchaseInfoSpList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        factoryName: null,
        factoryCode: null,
        danhao: null,
        yhDanhao: null,
        asnDanhao: null,
        classId: null,
        className: null,
        itemName: null,
        itemId: null,
        itemCode: null,
        spec: null,
        unit: null,
        txm: null,
        supplyId: null,
        supplyName: null,
        makerCode: null,
        makerName: null,
        contractCode: null,
        contractNum: null,
        contractShare: null,
        jhUnitPrice: null,
        jhTotalPrice: null,
        totalPrice: null,
        unitPrice: null,
        isTuoguan: null,
        yhNum: null,
        shNum: null,
        rkNum: null,
        hgNum: null,
        thNum: null,
        yhType: null,
        yhCompany: null,
        wlCompany: null,
        dhCompany: null,
        yhTime: null,
        dhStock: null,
        shName: null,
        shKuwei: null,
        shAddress: null,
        ghCompany: null,
        ghDate: null,
        ghAddress: null,
        scDate: null,
        gysYsjl: null,
        gysYssj: null,
        yddNum: null,
        ywcNum: null,
        yghwcbl: null,
        dxrl: null,
        ncgPlanId: null,
        ncgPlanNum: null,
        jcgPlanId: null,
        jcgPlanNum: null,
        ycgPlanId: null,
        ycgPlanNum: null,
        lscgPlanId: null,
        lscgPlanNum: null,
        size: null,
        singleWeight: null,
        totalWeight: null,
        rukuDate: null,
        upLine: null,
        downLine: null,
        stockSafe: null,
        useState: null,
        color: null,
        figure: null,
        caizhi: null,
        isDaizhi: null,
        packingNum: null,
        packingSize: null,
        packingCaizhi: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        cgName: null,
        shenhFlag: null,
        shenhTime: null,
        shenhRemark: null,
        shenhName: null,
        shenhState: null,
        remark: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加采购审批单";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getPurchaseInfoSp(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改采购审批单";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updatePurchaseInfoSp(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addPurchaseInfoSp(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除数据？').then(function() {
        return delPurchaseInfoSp(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('business/purchaseInfoSp/export', {
        ...this.queryParams
      }, `purchaseInfoSp_${new Date().getTime()}.xlsx`)
    },
    /** 导入按钮操作 */
    handleImport() {
      this.upload.title = "采购审批单导入";
      this.upload.open = true;
    },
    /** 下载模板操作 */
    importTemplate() {
      this.download('business/purchaseInfoSp/importTemplate', {
      }, `采购审批单模板.xlsx`)
    },
    /** 文件上传中处理 */
    handleFileUploadProgress(event, file, fileList) {
      this.upload.isUploading = true;
    },
    /** 文件上传成功处理 */
    handleFileSuccess(response, file, fileList) {
      this.upload.open = false;
      this.upload.isUploading = false;
      this.$refs.upload.clearFiles();
      this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true });
      this.getList();
    },
    /** 提交上传文件 */
    submitFileForm() {
      this.$refs.upload.submit();
    },
  }
};
</script>
